import { http } from "@/utils/http";
import { baseUrlApi } from "@/api/utils";
type Result = {
  current_page: number;
  result?: any;
  per_page?: number;
  total?: number;
  data?: any;
};
type ResultCreate = {
  code: number;
  msg: string;
  result: any;
};
type ResultDelete = {
  code: number;
  msg: string;
};
/** 用户列表 */
export const getUserListApi = (params?: object) => {
  return http.request<Result>("get", baseUrlApi + "/dashboard/user/list", {
    params
  });
};
/** 创建 */
export const createUserApi = (data?: object) => {
  return http.request<ResultCreate>("post", baseUrlApi + "/dashboard/user/store", {
    data
  });
};
/** 修改 */
export const updateUserApi = (data?: object) => {
  return http.request<ResultCreate>("put", baseUrlApi + "/dashboard/user/update", {
    data
  });
};
/** 删除 */
export const delUserApi = (data?: object) => {
  return http.request<ResultCreate>("delete", baseUrlApi + "/dashboard/user/delete", {
    data
  });
};
type Show = {
  code: number;
  msg: string;
  result?: any;
};
/** 用户详情 */
export const getUserShowApi = (params?: object) => {
  return http.request<Show>("get", baseUrlApi + "/dashboard/user/show", {
    params
  });
};
/** 用户职位列表 */
export const getJobTitleListApi = (params?: object) => {
  return http.request<Result>("get", "/dashboard/jobTitle/selectOptions", {
    params
  });
};
/** 用户状态修改 */
export const updateUserStatusApi = (data?: object) => {
  return http.request<ResultCreate>("put", "/dashboard/user/updateStatus", {
    data
  });
};
/** 修改用户密码 */
export const updateUserPassWordApi = (data?: object) => {
  return http.request<ResultCreate>("put", "/dashboard/user/updatePassword", {
    data
  });
};
/** 部门列表树 */
export const getDeptListApi = (params?: object) => {
  return http.request<Result>("get", "/dashboard/department/listTree", {
    params
  });
};

/** 用户选项 */
export const getUserSelectOptionsApi = (params?: object) => {
  return http.request<Show>("get", "/dashboard/user/selectOptions", {
    params
  });
};

/** 角色列表 */
export const getRbacRoleListApi = (params?: object) => {
  return http.request<Result>("get", "/dashboard/rbacRole/list", {
    params
  });
};
/** 角色添加 */
export const createRbacRoleApi = (data?: object) => {
  return http.request<ResultCreate>("post", "/dashboard/rbacRole/store", {
    data
  });
};
/** 角色修改 */
export const updateRbacRoleApi = (data?: object) => {
  return http.request<ResultCreate>("put", "/dashboard/rbacRole/update", {
    data
  });
};
/** 角色删除 */
export const delRbacRoleApi = (params?: object) => {
  return http.request<ResultDelete>("delete", "/dashboard/rbacRole/delete", {
    params
  });
};
/** 角色详情 */
export const getRbacRoleShowApi = (params?: object) => {
  return http.request<Show>("get", "/dashboard/rbacRole/show", {
    params
  });
};
/** 用户own详情 */
export const getUserOneselfShowApi = (params?: object) => {
  return http.request<Show>("get", "/dashboard/user/own", {
    params
  });
};
/** 用户own修改 */
export const updateUserOneselfApi = (data?: object) => {
  return http.request<ResultCreate>("put", "/dashboard/user/own", {
    data
  });
};
/** 菜单选择 */
export const getRbacMenuListTreeApi = (params?: object) => {
  return http.request<Result>("get", "/dashboard/rbacMenu/select", {
    params
  });
};
/** 部门列表 */
export const getDepartmentListApi = (params?: object) => {
  return http.request<Result>("get", "/dashboard/department/list", {
    params
  });
};
/** 部门添加 */
export const createDepartmentApi = (data?: object) => {
  return http.request<ResultCreate>("post", "/dashboard/department/store", {
    data
  });
};
/** 部门修改 */
export const updateDepartmentApi = (data?: object) => {
  return http.request<ResultCreate>("put", "/dashboard/department/update", {
    data
  });
};
/** 部门删除 */
export const delDepartmentApi = (params?: object) => {
  return http.request<ResultDelete>("delete", "/dashboard/department/delete", {
    params
  });
};
/** 部门详情 */
export const getDepartmentShowApi = (params?: object) => {
  return http.request<Show>("get", "/dashboard/department/show", {
    params
  });
};